<?php


namespace app\admin\controller;

use app\common\controller\AdminController;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;
use think\facade\Db;

/**
 * @ControllerAnnotation(title="达人审核列表")
 */
class ExpertReview extends AdminController
{

    use \app\admin\traits\Curd;
    protected $sort = [
        'id'   => 'desc',
    ];

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = new \app\admin\model\ServiceTechnician();
        
    }
    
    /**
     * @NodeAnotation(title="列表")
     */
    public function index()
    {
        if ($this->request->isAjax()) {
            list($page, $limit, $where) = $this->buildTableParames();
            $count = $this->model
                ->where($where)
                ->count();
            $list = $this->model
                ->where($where)
                ->page($page, $limit)
                ->order($this->sort)
                ->select();
            $data = [
                'code'  => 0,
                'msg'   => '',
                'count' => $count,
                'data'  => $list,
            ];
            return json($data);
        }
        return $this->fetch();
    }
 
    //驳回
    public function reject_url(){
        if ($this->request->isAjax()) {
            $post = $this->request->param();
            if(empty($post["reason_for_rejection"])){
                $this->error("参数不能为空");
            }
            $this->model->where("id",$post["id"])->update(["auditing_status"=>2,"reason"=>$post["reason_for_rejection"]]);
            $this->success('操作成功');
        }else{
            return $this->fetch();
        }
    }

    //通过
    public function adopt_url(){
        if ($this->request->isAjax()) {
            $post = $this->request->param();
            $this->model->where("id",$post["id"])->update(["auditing_status"=>1]);
            $this->success('操作成功');
        }
    }

    



    


 
    
 
} 